﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using SDM.ExamPlanner.BLL;
using SDM.ExamPlanner.DTO;

namespace sdm.exam.ui.ExamAdministration
{
    /// <summary>
    /// Interaction logic for EducationalExam.xaml
    /// </summary>
    public partial class EducationalExam : UserControl
    {
        Manager<Exam> _examManager = new Manager<Exam>();

        Dictionary<int, string> _examDictionary = new Dictionary<int, string>();

        public EducationalExam()
        {
            InitializeComponent();
            PopulateComboBox();
        }

        private void PopulateComboBox()
        {
            //too many with same ID
            _examDictionary = _examManager.Find().ToDictionary(item => item.Education.Id, item => item.Education.Name);
            cbbEducaction.DataContext = _examDictionary.Values;
        }

        private void cbbEducaction_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var selectedEducation = (string)cbbEducaction.SelectedValue;
            _examDictionary =
                _examManager.Find().Where(ex => ex.Education.Name==selectedEducation).ToDictionary(item => item.Id,
                                                                                                 item => item.Name);
        }
    }
}
